
__all__ = ['surgery_info']

class Multi_Language_VOC(object):
    def __init__(self, en_name, ch_name):
        self.en_name = en_name
        self.ch_name = ch_name

    @property
    def en(self):
        return self.en_name
    @property
    def ch(self):
        return self.ch_name

class AIS_Surgery_Short_VOC(object):
    EV = Multi_Language_VOC("End Vertebrae", "端椎")
    NV = Multi_Language_VOC("Neutural Vertebra", "中立椎")
    SV = Multi_Language_VOC("Stable Vertebra", "稳定椎")
    UIV = Multi_Language_VOC("Upper Instrument Vertebra", "最上固定椎")
    LIV = Multi_Language_VOC("Lower Instrument Vertebra", "最下固定椎")
    LTV = Multi_Language_VOC("Last Touching Vertebra", "最下触及椎")
    UEV = Multi_Language_VOC("Upper End Vertebra", "主弯上端椎")
    LEV = Multi_Language_VOC("Lower End Vertebra", "主弯下端椎")
    LSTV = Multi_Language_VOC("Last Substantially Touching Vertebra", "最后实质性触及椎")
    T2 = Multi_Language_VOC("T2", "T2椎体")

def surgery_template(UIV, LIV, ch=True, msg=""):
    if ch:
        return "{}是{}， {}是{}".format(AIS_Surgery_Short_VOC.UIV.ch, UIV.ch, AIS_Surgery_Short_VOC.LIV.ch, LIV.ch)
    else:
        return "{} is {}, {} is {}".format(AIS_Surgery_Short_VOC.UIV.en, UIV.en, AIS_Surgery_Short_VOC.LIV.en, LIV.en)


lenkes_UIV_LIV = (
    ((AIS_Surgery_Short_VOC.UEV, AIS_Surgery_Short_VOC.LSTV), (AIS_Surgery_Short_VOC.UEV, AIS_Surgery_Short_VOC.SV), (AIS_Surgery_Short_VOC.UEV, AIS_Surgery_Short_VOC.SV)),
    ((AIS_Surgery_Short_VOC.T2, AIS_Surgery_Short_VOC.LSTV), (AIS_Surgery_Short_VOC.T2, AIS_Surgery_Short_VOC.SV), (AIS_Surgery_Short_VOC.T2, AIS_Surgery_Short_VOC.SV)),
    ((AIS_Surgery_Short_VOC.UEV, AIS_Surgery_Short_VOC.LEV), (AIS_Surgery_Short_VOC.UEV, AIS_Surgery_Short_VOC.LEV), (AIS_Surgery_Short_VOC.UEV, AIS_Surgery_Short_VOC.LEV)),
    ((AIS_Surgery_Short_VOC.T2, AIS_Surgery_Short_VOC.LEV), (AIS_Surgery_Short_VOC.T2, AIS_Surgery_Short_VOC.LEV), (AIS_Surgery_Short_VOC.T2, AIS_Surgery_Short_VOC.LEV)),
    ((AIS_Surgery_Short_VOC.UEV, AIS_Surgery_Short_VOC.LEV), (AIS_Surgery_Short_VOC.UEV, AIS_Surgery_Short_VOC.LEV), (AIS_Surgery_Short_VOC.UEV, AIS_Surgery_Short_VOC.LEV)),
    ((AIS_Surgery_Short_VOC.UEV, AIS_Surgery_Short_VOC.LEV), (AIS_Surgery_Short_VOC.UEV, AIS_Surgery_Short_VOC.LEV), (AIS_Surgery_Short_VOC.UEV, AIS_Surgery_Short_VOC.LEV))
)


lumbar_correction_types = ("A", "B", "C")


def surgery_info(lenke_type, lumbar_correction_type, ch=True):
    if lumbar_correction_type not in lumbar_correction_types:
        return None
    if lenke_type not in list(range(1, (len(lenkes_UIV_LIV) + 1))):
        return None

    lumbar_correction_index = lumbar_correction_types.index(lumbar_correction_type)
    surgery_info_type = lenkes_UIV_LIV[lenke_type-1][lumbar_correction_index]

    return surgery_template(surgery_info_type[0], surgery_info_type[1], ch)



